package com.tjsinfo.tjsoa.addresslist.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.addresslist.bo.IAddressListUserBo;
import com.tjsinfo.tjsoa.common.DESPlus;
import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;

public class toReturnSynchronizationAction extends Action{
	private ISystemUserBo tjsUserBo;
	private IAddressListUserBo userBo;
	public void setUserBo(IAddressListUserBo userBo) {
		this.userBo = userBo;
	}
	public void setTjsUserBo(ISystemUserBo tjsUserBo) {
		this.tjsUserBo = tjsUserBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		String str = request.getParameter("str");
		String messageid = request.getParameter("messageid");
		try {
			DESPlus plus = new DESPlus();
			str = plus.decrypt(str);
		} catch (Exception e) {
		}
		String[] s = str.split("#");
		String tjsUserId = s[0];
		Integer jieshouuser = Integer.valueOf(s[1]);
		List list = userBo.getAddresssListUserByUserIdState(Integer.valueOf(tjsUserId));
		String bl = "true";
		if (list.size() > 0) {
			bl = "false";
		}
		
		TSystemUser tjsUser = tjsUserBo.findByIdSystemUser(Integer.valueOf(tjsUserId));
		request.setAttribute("tjsUser", tjsUser);
		request.setAttribute("messageid", messageid);
		request.setAttribute("userid", jieshouuser);
		request.setAttribute("bl", bl);
		return mapping.findForward("ok");
	}
}
